import request from "@/api/config";
import { AxiosPromise } from 'axios';
import {PORT} from "@/leadmall/api/config/servicePort";
import { AdminVO, AdminForm, AdminQuery } from '@/leadmall/api/admin/types';

/**
 * 查询员工列表
 * @param query
 * @returns {*}
 */

export const listAdmin = (query?: AdminQuery): AxiosPromise<AdminVO[]> => {
  return request({
    url: PORT +'/leadmall/admin/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询员工详细
 * @param id
 */
export const getAdmin = (id: string | number): AxiosPromise<AdminVO> => {
  return request({
    url: PORT +'/leadmall/admin/' + id,
    method: 'get'
  });
};

/**
 * 新增员工
 * @param data
 */
export const addAdmin = (data: AdminForm) => {
  return request({
    url: PORT +'/leadmall/admin',
    method: 'post',
    data: data
  });
};

/**
 * 修改员工
 * @param data
 */
export const updateAdmin = (data: AdminForm) => {
  return request({
    url: PORT +'/leadmall/admin',
    method: 'put',
    data: data
  });
};

/**
 * 删除员工
 * @param id
 */
export const delAdmin = (id: string | number | Array<string | number>) => {
  return request({
    url: PORT +'/leadmall/admin/' + id,
    method: 'delete'
  });
};
